1. Field of the Invention
The present invention relates to computer graphics systems and, more particularly to a system and method for implementing accumulation operations in hardware.
2. Discussion of the Related Art
Computer graphics systems commonly are used for displaying graphical representations of objects on a two dimensional display screen. Current computer graphics systems can provide highly detailed representations and are used in a variety of applications.
In typical computer graphics systems, an object to be represented on the display screen is broken down into a plurality of graphics primitives. Primitives are basic components of a graphics picture and may include points, lines, vectors and polygons, such as triangles. Typically, a hardware/software scheme is implemented to render, or draw, on the two-dimensional display screen, the graphics primitives that represent the view of one or more objects being represented on the screen.
Typically, the primitives that define the three-dimensional object to be rendered are provided from a host computer, which defines each primitive in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitive in terms of the x,y,z coordinates of its vertices, as well as the R,G,B color values of each vertex. Rendering hardware interpolates the primitive data to compute the display screen pixels that are turned on to represent each primitive, and the R,G,B values for each pixel.
Early graphics systems failed to display images in a sufficiently realistic manner to represent or model complex three-dimensional objects. The images displayed by such systems sometimes exhibited extremely smooth surfaces absent textures, bumps, scratches, shadows and other surface details present in the object being modeled. In addition, early graphics systems often suffered from poor image quality, due to phenomenon such as aliasing.
As is known, accumulation buffers have been used in graphical image processing to accomplish a number of effects, including anti-aliasing, motion blur, enhanced depth perception, and soft shading. In general, an accumulation buffer is used to combine multiple frames to produce a composite frame. Each of the multiple frames is typically combined with the accumulation buffer by calculating, for each pixel of the frame, a weighted average of the pixel with a corresponding pixel of the accumulation buffer. Each of the above-listed effects are achieved by altering a single graphical image slightly to produce a number of slightly different frames and accumulating the frames in the accumulation buffer.
To more particularly illustrate the foregoing, aliasing refers to jagged edges on graphical objects represented in a rasterized image. For example, a line which is slanted, i.e., neither fully horizontal nor fully vertical, appears to be jagged when displayed in a rectangular grid of pixels of a computer display device. The jagged quality is a result of rounding floating point values to integer pixel addresses. Anti-aliasing generally refers to graphical alteration of a graphical object or image to remove the appearance of jagged edges. An accumulation buffer is used to produce an anti-aliased image by xe2x80x9cjitteringxe2x80x9d the image. In other words, the graphical image is rendered into the accumulation buffer. Then the graphical image is translated (i.e., moved) by a fraction of a pixel and is rendered again to produce a slightly translated frame. Rendering the graphical image as translated causes the jags in the various edges of the various graphical objects rendered to appear in slightly different places. The slightly translated frame is then accumulated with the previously rendered frame in the accumulation buffer and the resulting frame is stored in the accumulation buffer. The translation, rendering and accumulation of frames of the graphical image is repeated a number of times. The result is an averaging of a number of frames in which jags in the edges of graphical objects in a graphical image are smoothed, providing the appearance of smooth edges.
An accumulation buffer may also be used in a similar fashion to blur graphical objects in motion. In computer generated animation, objects in motion often have no blur, i.e., appear to have very sharp edges. When an object with sharp edges moves quickly across a television or movie screen or across a computer display device in a motion video display, the appearance is very unnatural and disturbing to the viewer. To achieve a more natural blurring of the object in motion, a graphical image in which an object is in motion is repeatedly rendered with the object in different position along the path of motion of the object and the resulting frames are accumulated in the accumulation buffer. The resulting accumulated frame includes an image of the moving graphical object which is blurred along the path of motion of the graphical object and a considerably more natural and pleasing animated video display.
An accumulation buffer may also be used to enhance depth perception in a three-dimensional graphical image. Depth perception is enhanced by blurring graphical objects distant from the viewer while preserving sharpness in graphical objects nearer the viewer. This result is achieved by repeatedly rendering the three-dimensional image from slightly varying perspectives. Altering the perspective of a three-dimensional graphical image results in greater movement of graphical object further from the viewer relative to movement of objects nearer the viewer. Accumulation of frames corresponding to slightly varied perspectives therefore results in blurring of graphical objects substantially proportional to the distance of the graphical objects from the viewer. Thus, depth perception in the rendered and accumulated graphical image is enhanced substantially.
An accumulation buffer may further be used to soften shadows in a rendered graphical image. Because of the precision of computers in rendering three-dimensional graphical images, shadows portrayed in such rendered graphical images are particularly sharp, resulting in an unnatural, surreal appearance of the graphical image. Shadows in such a graphical image are softened by repeatedly rendering the graphical image with the respective positions of various virtual light sources, which define the lighting characteristics of the graphical image, varied slightly and the resulting frames are accumulated in the accumulation buffer. Since each frame corresponds to a slightly different light source position, shadows in each frame are in a slightly different position. The accumulated frame in the accumulation buffer therefore has softer shadows, as if from a more diffused light source. The resulting displayed graphical image is more natural and realistic.
The OpenGL specification includes an accumulation buffer, which is a per-pixel screen resource, which allows applications to periodically accumulate partially rendered scenes, and then, when the full scene has rendered, put the final result back into the frame buffer. As previously mentioned, applications for the accumulation buffer include full scene antialiasing, motion blur, enhanced depth perception, and soft shading.
As is known, some of the operations which may be performed by the accumulation buffer are: Clear, Load, Accumulate, Multiply, Add, and Return. The Clear operation clears the entire contents of the accumulation buffer to a specified color (typically black). The Load operation copies the contents of the frame buffer into the accumulation buffer. The Accumulate operation multiplies the contents of the frame buffer (on a per-pixel basis) by a supplied number and adds the results to the contents of the accumulation buffer. The Multiply operation multiplies the contents of the accumulation buffer by a supplied number. The Add operation adds a supplied number to each component of the accumulation buffer. Finally, the Return operation multiplies the contents of the accumulation buffer by a supplied number and returns the number to the frame buffer.
Typically, the accumulation buffer operations listed above are implemented in software. As should be appreciated, particularly for high resolution applications, the foregoing operations require the execution of a large number of instructions. Therefore, implementing these operations in software is relatively time consuming. However, adding dedicated hardware to an existing system to accelerate the execution of these operations is costly.
Accordingly, it is desired to provide a system and method that provide improved performance in the execution of accumulation buffer operations, particularly in an OpenGL compliant system.
Certain objects, advantages and novel features of the invention will be set forth in part in the description that follows and in part will become apparent to those skilled in the art upon examination of the following or may be learned with the practice of the invention. The objects and advantages of the invention may be realized and obtained by means of the instrumentalities and combinations particularly pointed out in the appended claims.
To achieve the advantages and novel features, the present invention is generally directed to a system and method for performing accumulation buffer operations using texture mapping hardware. In accordance with one aspect of the invention, a method is provided that operates by allocating a texture map of equal size as a display screen and copying contents of a frame buffer to the allocated texture map. The method then identifies an accumulation buffer operation and performs the accumulation buffer operation in a fragment unit. Preferably, the fragment unit includes an arithmetic logic unit (ALU) to perform high-speed mathematical operations. Finally, the method directs results of the accumulation buffer operation to the frame buffer, and copies contents of the frame buffer to the allocated texture map.